/* * Copyright 2020-2021, www.SuperSignature.com * This code is not a freeware. You need to buy it before use! * ver 1.5.0.4 September 2019 */ window.$ = window.$ || jQuery.noConflict(); ValidateSignature=function(b){var g=!0;if(null==b||"undefined"==b||""==b)for(b=0;b"+V.innerHTML}catch(c){alert(c.description)}}function p(a){a=a.replace("undefined ","");a=a.replace("undefined","");var c="",d,f=0;a=a.replace(/\x0d\x0a/g,"\n");var l="";for(d=0;du?l+=String.fromCharCode(u):(127u?l+=String.fromCharCode(u>>6|192):(l+=String.fromCharCode(u>>12|224),l+=String.fromCharCode(u>>6&63|128)),l+=String.fromCharCode(u&63|128))}for(a=l;f>2;A=(A&3)<<4|l>>4;var Y=(l&15)<<2|d>>6;var v=d&63;isNaN(l)?Y=v=64:isNaN(d)&&(v=64);c=c+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(u)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(A)+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Y)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(v)}return c}function r(){w[0]=0;for(var a=1;a=ra?!0:!1;sa=w[0];a="";J[0]="1,"+W+","+ta+","+F+","+G+","+oa+","+w[0]+","+C+";";for(var c=0;c=J.length)this.ResetClick();else{J.pop();P.pop();w.pop();ba.pop();r();var a="'"+H.value+"'";var c= "",d=0;/[^A-Za-z0-9\+\/=]/g.exec(a);a=a.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));f=f<<2|l>>4;l=(l&15)<<4|u>>2;var Y=(u& 3)<<6|A;c+=String.fromCharCode(f);64!=u&&(c+=String.fromCharCode(l));64!=A&&(c+=String.fromCharCode(Y))}while(d');e.pathCoordString=za;e.insertAdjacentHTML("beforeEnd",Ea)}else e.beginPath(),e.lineJoin="round",e.lineCap="round",e.moveTo(x,v);2==u.length&&eval("obj"+C).DrawDot(x,v)}else if(x= Math.abs(parseInt(x,0)*c),v=Math.abs(parseInt(v,0)*c),isIE||ia){if(e.pathCoordString+=" "+x+","+v,x=document.getElementById(C+"_l_"+(f-1)))if(x=x.firstChild)try{x.setAttribute("v",e.pathCoordString+" e")}catch(Fa){}}else e.strokeStyle=U,e.lineWidth=L,e.lineTo(x,v),e.stroke(),e.moveTo(x,v);isIE?e.innerHTML=e.innerHTML:(e.closePath(),e.restore())}B++}!isIE&&ia&&q(c);r()};this.TextSignature=function(a,c,d,f){da&&(e.font=a,e.fillText(c,d,f))};this.CheckCompatibility=function(){if(isIE)this.IsCompatible= !0,isMobileIE||document.namespaces.SuperSignature||document.namespaces.add("SuperSignature","urn:schemas-microsoft-com:vml","#default#VML");else{try{da=!!document.createElement("canvas").getContext("2d")}catch(a){da=!!document.createElement("canvas").getContext}da?this.IsCompatible=!0:document.write("Your browser does not support our signature control.")}};this.MouseMove=function(a){if(I&&pa){"undefined"!==typeof a.originalEvent&&(a=a.originalEvent);M(a);var c=$("#"+m.id).offset();if(D&&"undefined"!== typeof a.targetTouches){var d=a.targetTouches[0];var f=d.clientX-ma;d=d.clientY-la;ja&&(d-=parseInt($(document).scrollTop()),f-=parseInt($(document).scrollLeft()))}else a.originalEvent?a.pageX?(f=parseInt(a.pageX-c.left),d=parseInt(a.pageY-c.top)):(f=parseInt(a.originalEvent.pageX-c.left),d=parseInt(a.originalEvent.pageY-c.top)):isIE||isIENine?(f=parseInt(a.x),d=parseInt(a.y),9<=iever&&(f=parseInt(a.pageX-c.left),d=parseInt(a.pageY-c.top))):(f=parseInt(a.pageX-c.left),d=parseInt(a.pageY-c.top));fa&& ha&&(f=parseInt(a.offsetX||a.layerX),d=parseInt(a.offsetY||a.layerY));(ca||ea)&&-1==a.type.indexOf("touch")&&(f=a.clientX-O.getBoundingClientRect().left,d=a.clientY-O.getBoundingClientRect().top);isMobileIE?K.push(Math.abs(parseInt(f)-parseInt(m.offsetLeft))+","+Math.abs(parseInt(d)-parseInt(m.offsetTop))):K.push(Math.abs(parseInt(f))+","+Math.abs(parseInt(d)));w[B]++;if(isIE)if(isMobileIE){if(a=f-Z,c=d-aa,64')):(e.arc(a,c,L/2,0,2*Math.PI,!1),e.fill(),e.stroke())};this.MouseOut=function(a){I&&(M(a),h("Mouse out"),ka||X())};this.MouseUp=function(a){if(I){"undefined"!==typeof a.originalEvent&&(a=a.originalEvent);M(a);h("Mouse up");if(null!=na){var c=parseInt(new Date-na);if(125>c){h("Time diff "+c);if(D)c=wa,a=xa;else{var d=$("#"+m.id).offset();a.originalEvent?a.pageX?(c=parseInt(a.pageX-d.left),a=parseInt(a.pageY-d.top)): (c=parseInt(a.originalEvent.pageX-d.left),a=parseInt(a.originalEvent.pageY-d.top)):isIE||isIENine?(c=parseInt(a.x),a=parseInt(a.y)):(c=parseInt(a.pageX-d.left),a=parseInt(a.pageY-d.top))}isIE&&(h("Drawing Dot At ("+c+","+a+")"),eval("obj"+C).DrawDot(c,a))}na=null}ka||X()}};this.MouseDown=function(a){if(I){"undefined"!==typeof a.originalEvent&&(a=a.originalEvent);M(a);na=new Date;pa=!0;ka=!1;if(D&&"undefined"!==typeof a.targetTouches){var c=a.targetTouches[0];ma=O.getBoundingClientRect().left;la=O.getBoundingClientRect().top; var d=c.clientX-ma;c=c.clientY-la;ja&&(c-=parseInt($(document).scrollTop()),d-=parseInt($(document).scrollLeft()));wa=d;xa=c}else{var f=$("#"+m.id).offset();a.originalEvent?a.pageX?(d=parseInt(a.pageX-f.left),c=parseInt(a.pageY-f.top)):(d=parseInt(a.originalEvent.pageX-f.left),c=parseInt(a.originalEvent.pageY-f.top)):isIE||isIENine?9>iever?(d=parseInt(a.x),c=parseInt(a.y)):isIENine&&(d=parseInt(a.pageX)-parseInt(f.left)+parseInt($("html").css("margin-left")),c=parseInt(a.pageY)-parseInt(f.top)+parseInt($("html").css("margin-top")), 10<=iever&&(d=parseInt(a.pageX-f.left),c=parseInt(a.pageY-f.top))):(d=parseInt(a.pageX-f.left),c=parseInt(a.pageY-f.top))}fa&&ha&&(d=parseInt(a.offsetX||a.layerX),c=parseInt(a.offsetY||a.layerY));(ca||ea)&&-1==a.type.indexOf("touch")&&(d=a.clientX-O.getBoundingClientRect().left,c=a.clientY-O.getBoundingClientRect().top);h("Down ("+d+","+c+")");B++;w[B]=0;K.length=0;K[0]=L+","+U;isMobileIE?K.push(Math.abs(parseInt(d)-parseInt(m.offsetLeft))+","+Math.abs(parseInt(c)-parseInt(m.offsetTop))):K.push(Math.abs(parseInt(d))+ ","+Math.abs(parseInt(c)));isIE?isMobileIE?(Z=d,aa=c):(a='"m'+d+","+c+" l"+d+","+c,d=''),e.pathCoordString=a,e.insertAdjacentHTML("beforeEnd",d)):(e.save(),e.beginPath(),e.lineJoin="round",e.lineCap="round",e.strokeStyle= U,e.lineWidth=L,e.moveTo(d,c));return!1}};this.ResetClick=function(a){I&&(isMobileIE||(document.getElementById(C).style.borderColor=Ca),isIE?(e.innerHTML="",isMobileIE&&(aa=Z=0,null!=E&&"undefined"!=E&&(E.clear(),E.paint())),0";$("#"+this.SignObject).replaceWith(a);h("DIV changed to CANVAS");isIE=!1}}else"CANVAS"==document.getElementById(this.SignObject).nodeName.toUpperCase()&&(a="
",$("#"+this.SignObject).replaceWith(a),h("CANVAS changed to DIV"),isIE=!0);V=document.getElementById(this.SignObject+"_Debug");e=document.getElementById(this.SignObject);m=document.getElementById(this.SignObject+"_Container");if(e.addEventListener)h("addEventListener supported");else if(e.attachEvent)h("attachEvent supported");else{h("Mouse events are not supported");return}this.mouseMoved=!1;if(null!=e&&"undefined"!=e){h("Objects OK");isIE&&!isMobileIE&& (ua=document.documentMode?8<=document.documentMode:!1);isMobileIE&&h("Mobile IE");isIENine&&h("IE 9 Or Above");isOperaMini&&h("Opera Mini, not supported.");w[0]=0;J[0]="1,"+W+","+ta+","+F+","+G+","+oa+","+w[0]+","+C+";";if(this.ApplyStyle){h("Setting up style");m.style.zIndex=this.SignzIndex;try{isMobileIE?(m.style.borderWidth=this.BorderWidth,m.style.borderStyle=this.BorderStyle,m.style.borderColor=this.BorderColor,m.style.backgroundColor=this.BackColor,0Clear Signature'; a+='
'+this.StartMessage+"
";a+=null==document.getElementById(this.SignObject+"_data")?'':"";a+=null==document.getElementById(this.SignObject+"_data_smooth")?'': "";a+=null==document.getElementById(this.SignObject+"_data_canvas")?'':"";a+="";h("Setting up tools");$("#"+m.id).after(a);B=0;a="mousedown";var c="mouseup",d="mousemove",f="mouseout";isIE&&(f="mouseleave");isAndroid=-1b.length)return b[0];this.points=[];for(var k=0;k= h;h++){if(p=this.gB(b,g,q,k,n),r=this.fM(b,g,p,q),r.error=y)break;this.rP(b,g,q,p);y=r.error}q=this.points[t-1].MathFunc2(this.points[t]);y=this.points[t].MathFunc2(this.points[t+1]);q=q.MathFunc1(y).MathFunc4(2).nOR();this.processFitPoints(b,t,k,q);this.processFitPoints(t,g,q.MathFunc5(),n)}},savePoints:function(b){this.result.push({x:this.r2(b[1].x),y:this.r2(b[1].y+this.offSet)});this.result.push({x:this.r2(b[2].x),y:this.r2(b[2].y+this.offSet)}); this.result.push({x:this.r2(b[3].x),y:this.r2(b[3].y+this.offSet)})},r2:function(b){return Math.round(100*b)/100},gB:function(b,g,k,n,h){var p=1E-11,r=this.points[b],t=this.points[g],q=[[0,0],[0,0]],y=[0,0],X,M,N,B,D,e,O,m,Q=0;for(g=g-b+1;Qp?(B=q[0][0]*y[1]-q[1][0]*y[0],D=y[0]*q[1][1]-y[1]*q[0][1],M=D/X,N=B/X):(e=q[0][0]+q[0][1],O=q[1][0]+q[1][1],M=Math.abs(e)>p?N=y[0]/e:Math.abs(e)>p?N=y[1]/O:N=0),m=t.MathFunc6(r),p*=m,(M=p;p++)n[p]=b[p+1].MathFunc2(b[p]).MathFunc3(3);for(p=0;1>=p;p++)h[p]=n[p+ 1].MathFunc2(n[p]).MathFunc3(2);b=this.eV(3,b,k);n=this.eV(2,n,k);h=this.eV(1,h,k);g=b.MathFunc2(g);h=n.dot(n)+g.dot(h);return 1E-5>Math.abs(h)?k:k-g.dot(n)/h},eV:function(b,g,k){g=g.slice();for(var n,h=1;h<=b;h++)for(n=0;n<=b-h;n++)g[n]=g[n].MathFunc3(1-k).MathFunc1(g[n+1].MathFunc3(k));return g[0]},cLP:function(b,g){for(var k=[0],n,h=b+1;h<=g;h++)k[h-b]=k[h-b-1]+this.points[h].MathFunc6(this.points[h-1]);h=1;for(n=g-b;h<=n;h++)k[h]/=k[n];return k},fM:function(b,g,k,n){for(var h=Math.floor((g-b+ 1)/2),p=0,r=b+1;r=p&&(p=t,h=r)}return{error:p,index:h}}};Smooth=function(b,g){this.x=b;this.y=g}; Smooth.prototype={CheckPtArray:function(b){return"number"==typeof b?{x:b,y:b}:b},MathFunc1:function(b){b=this.CheckPtArray(b);return SmoothRet(this.x+b.x,this.y+b.y)},MathFunc2:function(b){b=this.CheckPtArray(b);return SmoothRet(this.x-b.x,this.y-b.y)},MathFunc3:function(b){b=this.CheckPtArray(b);return SmoothRet(this.x*b.x,this.y*b.y)},MathFunc4:function(b){b=this.CheckPtArray(b);return SmoothRet(this.x/b.x,this.y/b.y)},MathFunc5:function(){return SmoothRet(-this.x,-this.y)},MathFunc6:function(b, g){var k=b.x-this.x,n=b.y-this.y;k=k*k+n*n;return g?k:Math.sqrt(k)},getLength:function(b){var g=this.x*this.x+this.y*this.y;return b?g:Math.sqrt(g)},nOR:function(b){void 0===b&&(b=1);var g=this.getLength();b=0!=g?b/g:0;return SmoothRet(this.x*b,this.y*b)},CheckValid:function(b){return null==b?!1:this.x==b.x&&this.y==b.y},dot:function(b){return this.x*b.x+this.y*b.y}};var SmoothRet=function(b,g){return new Smooth(b,g)}; Compress=function(b,g){var k=0,n=0,h=b.length,p="",r;g=Math.pow(10,g);for(r=0;rb&&(b=~b);for(g="";32<=b;)g+=String.fromCharCode((32|b&31)+63),b>>=5;return g+String.fromCharCode(b+63)}; String.prototype.replaceAll=function(b,g,k){return this.replace(new RegExp(b.replace(/([\/,!\\\^\$\{\}\[\]\(\)\.\*\+\?\|<>\-&])/g,"\\$&"),k?"gi":"g"),"string"==typeof g?g.replace(/\$/g,"$$$$"):g)}; /* End */